package cn.itcast.dao;

import cn.itcast.pojo.Permission;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


public interface PermissionDao {

    /**
     *  查询全部
     */
    @Select("select * from t_permission ")
    Page<Permission> selectByCondition(String queryString);

    /**
     *  新增权限
     *
     */
    @Insert("insert into t_permission values(#{id},#{name},#{keyword},#{description})")
    void add(Permission permission);

    /**
     *  根据id删除权限
     *
     */
    @Delete("delete from t_permission where id=#{id}")
    void deleteById(Integer id);

//    /**
//     *  修改权限
//     *
//     */
//    @Update("update t_permission set name=#{name},keyword=#{keyword} where id=#{id}")
//    void updateById(Permission permission);


    /**
     *  根据id查询
     * @param id
     */
    @Select("select * from t_permission where id=#{id}")
    Permission findById(Integer id);


    @Select("select * from t_permission")
    List<Permission> findAll();

    /**
     *  编辑权限
     * @param permission
     */
    @Update("update t_permission set name=#{name},keyword=#{keyword},description=#{description} where id=#{id}" )
    void edit(Permission permission);

    List<Permission> findPermissionList(List<Integer> menuIds);
}
